<template>
  <div>
    <div class="alarm">
      <div class="box">
        <span class="red">
        <span class="img"><img src="/src/assets/images/u7655.png"></span>
        <span class="all">
          <span class="title">红色报警</span><br>
        <span class="count">{{ alarmCount.redCount }}</span>
        </span>
      </span>
      </div>
      <div class="box">
        <span class="yellow">
        <span class="img"><img src="/src/assets/images/u7656.png"></span>
        <span class="all">
          <span class="title">黄色报警</span><br>
        <span class="count">{{ alarmCount.yellowCount }}</span>
        </span>
      </span>
      </div>
      <div class="box">
        <span class="normal">
        <span class="img"><img src="/src/assets/images/u7657.png"></span>
        <span class="all">
          <span class="title">正常状态</span><br>
        <span class="count">{{ alarmCount.normal }}</span>
        </span>
      </span>
      </div>
    </div>
  </div>

</template>

<script lang="ts" setup>
import {Pipe} from "../../../types/tanTypes/pipe";
import {computed} from "vue";
import {usePipeStore} from "../../../store/pipe";

// 警告
const pipStore = usePipeStore()
const alarmCount = computed(() => {
  let redCount = 0
  let yellowCount = 0
  let normal = 0
  pipStore.pipeData.forEach((item: Pipe) => {
    redCount += item.redAlarm
    yellowCount += item.yellowAlarm
    normal = item.totalCount - (redCount + yellowCount)
  })
  return {redCount, yellowCount, normal}
})



</script>

<style lang="scss" scoped>
.alarm {
  //width: 100%;
  color: #666666;
  display: flex;
  width: 740px;
  margin: 100px auto;
  .box {
    margin: 0 55px;
  }
  span {
    display: inline-block;
  }
  .img {
    width: 50px;
    height: 50px;
    border-radius: 25px;
    background-color: #cccccc;
    line-height: 50px;
    margin-top: 10px;
    img {
      margin-top: 10px;
    }
  }
  .all {
    margin-left: 20px;

  }
  .title {
    padding-top: 10px;
    font-size: 14px;
    margin-bottom: 10px;
  }
  .count {
    font-size: 25px;
    font-weight: 900;
  }
}
.normal {

}
</style>
